//===============================================================================
// XGenPlus Tool
// ==============================================================================
// Please visit http://www.codeplex.com/xgenplus for latest updates.
//
// This source is subject to the GNU General Public License v2.
// 
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Text;

namespace XGenPlus.SerializerLib
{
    public static class FactoryProxy
    {
        /// <summary>
        /// Get the factory from the cache, and get the appropriate serializer
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public static System.Xml.Serialization.XmlSerializer GetSerializer(Type t)
        {
            ISerializerFactory fact = FactoryCache.GetFactory(t);
            try
            {
                if (fact != null)
                    return fact.GetSerializer(t);

                return new System.Xml.Serialization.XmlSerializer(t);
            }
            catch
            {
                return new System.Xml.Serialization.XmlSerializer(t);
            }
        }
    }
}
